// import { loginUser } from '@/api/user'
import { getToken, setToken, removeToken } from '@/utils/auth'
// import { resetRouter } from '@/router'
// vuex模块代码提示
/**
 * @type {import('vuex').Module}
 */
const user = {
  namespaced: true,
  state: {
    token: getToken(),
    userInfo: JSON.parse(localStorage.getItem('userInfo'))
  },
  mutations: {
    setTokenVuex(state, token) {
      setToken(token)
      state.token = token
    },
    removeTokenVuex(state, token) {
      removeToken()
      state.token = null
    },
    removeUserInfoVuex(state, token) {
      localStorage.removeItem('userInfo')
      state.userInfo = {}
    }
  }
}

export default user
